﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Store.aspx.cs" Inherits="Store" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>仓库数据</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="/scripts/boot.js" type="text/javascript"></script>
    <style type="text/css">
        .mini-summary-row
        {
            background-color: #FFFFE6;
        }
        html, body
        {
            margin: 0;
            padding: 0;
            border: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div style="width: 100%;" runat="server" id="operationPanel">
        <div class="mini-toolbar" style="border-bottom: 0; padding: 0px;">
            <table style="width: 100%;">
                <tr>
                    <td style="width: 100%;">
                        <a class="mini-button" iconcls="icon-remove" runat="server" id="btnDelete" onclick="deleteRows()"
                            plain="true">删除</a>
                    </td>
                    <td style="white-space: nowrap;">
                        <input id="key" class="mini-textbox" emptytext="请输入关键字" style="width: 280px;" onenter="onKeyEnter" />
                        <a class="mini-button" onclick="search()" iconcls="icon-search"></a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 100%;" allowresize="true"
            pagesize="100" allowcellselect="true" multiselect="true" allowcelledit="false"
            oncellendedit="cellendedit" allowcellvalid="true" editnextonenterkey="true" editnextrowcell="true"
            url="/Handler/Store.ashx?method=LoadData&ticket=5234108899" idfield="Index">
            <div property="columns">
                <div type="indexcolumn" headeralign="center" allowsort="true">
                    序号</div>
                <div type="checkcolumn">
                </div>
                <div name="Account" field="Account" headeralign="center" allowsort="true" width="100">
                    账号
                </div>
                <div name="ServerID" field="ServerID" headeralign="center" allowsort="true" width="100">
                    服务器
                </div>
                <div name="Character" field="Character" headeralign="center" allowsort="true" width="150">
                    角色
                </div>
                <div name="ID" field="ID" headeralign="center" allowsort="false" width="200">
                    编号
                </div>
                <div name="Diamond" field="Diamond" headeralign="center" allowsort="true" width="100">
                    钻石
                </div>
                <div name="Info" field="Info" headeralign="center" allowsort="true" width="100%">
                    物品
                </div>
                <div name="edit" width="150" align="center" headeralign="center">
                    操作
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        grid.on("drawcell", function (e) {
            var column = e.column;
            if (column.name == "edit") {
                e.cellStyle = "text-align:center";
                e.cellHtml = '<a href="javascript:deleteRow(' + e.rowIndex + ')">删除</a>';
            }
        });

        search();

        function search() {
            var key = mini.get("key").getValue();
            grid.sortBy("ServerID", "desc");
            grid.load({ key: key });
        }

        function onKeyEnter(e) { search(); }

        function deleteRow(rowIndex) {
            var array = new Array(); var rowData = grid.getRow(rowIndex); array.push(rowData.Index);
            delStory(array);
        }

        function deleteRows() {
            var array = new Array();
            var datas = grid.getSelecteds();
            if (1 > datas.length) { $.notify("请选择要删除的行记录"); return; }
            for (var i = 0; i < datas.length; i++) { array.push(datas[i].Index); } delData(array);
        }

        function delData(ids) {
            $.confirm("确定删除吗？", function (action) {
                if ('是' != action) { return; }
                mask();
                $.ajax({ url: "/Handler/Store.ashx?method=Delete&ticket=5234108899",
                    data: { data: mini.encode(ids) },
                    type: "post",
                    success: function (result) {
                        if (result.Success) { grid.reload(); }
                        else {
                            $.alert("操作失败" + result.Message);
                        }
                        unmask();
                    }, error: function (jqXHR, textStatus, errorThrown)
                    { $.alert(jqXHR.responseText); unmask(); }
                });
            });
        }
    </script>
</body>
</html>
